<script setup>
import { ref, onMounted } from 'vue'
import { useRoute } from 'vue-router'
import { ElMessage } from 'element-plus'
import axios from 'axios'

const route = useRoute()
const notice = ref({})

const fetchNotice = async () => {
  try {
    const res = await axios.get(`http://localhost:8080/orgs/getAnnouncementById/${route.params.id}`)
    if (res.data && res.data.code === 200) {
      notice.value = res.data.data
    } else {
      ElMessage.error(res.data && res.data.msg ? res.data.msg : '获取公告详情失败')
    }
  } catch (e) {
    ElMessage.error('获取公告详情失败')
  }
}

onMounted(fetchNotice)
</script>
<template>
  <el-card>
    <h2>{{ notice.title }}</h2>
    <p><strong>内容：</strong>{{ notice.content }}</p>
    <p><strong>更新时间：</strong>{{ notice.updateTime }}</p>
    <p><strong>管理员ID：</strong>{{ notice.adminId }}</p>
  </el-card>
</template>